﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chinaer.Web
{
    public partial class Province : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Bind();
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var  result = CommonService.GetChinaerService.AddProvince(new DTO.ProvinceDTO()
               {
                   CountryID = this.ddlCountry.SelectedValue,
                   CreateTime = DateTime.Now,
                   IsDelete = false,
                   IsUse = true,
                   Name = this.txtProvinceName.Text.Trim()
               });
            Response.Write(result);
            Bind();
        }
        private void Bind()
        {
            List<DTO.CountryDTO> listCountry = CommonService.GetChinaerService.GetAllCountry("");
            this.ddlCountry.DataSource = listCountry;
            this.ddlCountry.DataTextField = "CountryName";
            this.ddlCountry.DataValueField = "ID";
            this.ddlCountry.DataBind();
        }
    }
}